from zhipuai import ZhipuAI


class WebSearch:
    def __init__(self):
        self._client = ZhipuAI(
            api_key="802580dc2848935a189cac7ae33af594.2SWW3iXZKAOPqXXF"
        )
        self._tools = [
            {
                "type": "web_search",
                "web_search": {
                    "enable": True  # 默认为关闭状态（False） 禁用：False，启用：True。
                },
            }
        ]

    def __call__(self, query):
        messages = [
            {
                "role": "user",
                "content": query,
            }
        ]

        response = self._client.chat.completions.create(
            model="glm-4",
            messages=messages,
            tools=self._tools,
        )


webSearch = WebSearch()


class RAG:
    def __init__(self):
        pass
        